﻿
    using Chain.BLL;
    using System;
    using System.Data;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using Wuqi.Webdiyer;

    public partial class CouponManage : PageBase
    {


        public void CouponGetList()
        {
            Coupon coupon = new Coupon();
            int Counts = this.NetPagerParameter.RecordCount;
            DataTable db = coupon.GetListSP(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[] { "" }).Tables[0];
            this.NetPagerParameter.RecordCount = Counts;
            this.gvCouponList.DataSource = db;
            this.gvCouponList.DataBind();
            PageBase.BindSerialRepeater(this.gvCouponList, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
        }

        protected void drpPageSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.NetPagerParameter.CurrentPageIndex = 1;
            this.NetPagerParameter.PageSize = int.Parse(this.drpPageSize.SelectedValue);
            this.CouponGetList();
        }

        public string GetCouponEffective(string strType, string strStartTime, string strEndTime)
        {
            if (strType == "0")
            {
                return "<span style='color:red;'>永久有效</span>";
            }
            return (Convert.ToDateTime(strStartTime).ToShortDateString() + "至" + Convert.ToDateTime(strEndTime).ToShortDateString());
        }

        protected void NetPagerParameter_PageChanging(object src, PageChangingEventArgs e)
        {
            this.NetPagerParameter.CurrentPageIndex = e.NewPageIndex;
            this.CouponGetList();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.CouponGetList();
            }
        }
    }


